package com.pinyougou.manager.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: Feng.Wang
 * @Company: Zelin.ShenZhen
 * @Description:
 * @Date: Create in 2019/7/12 10:10
 */
@RestController
@RequestMapping("/login")
public class LoginController {
    /**
     * 得到当前登录的用户名
     * @return
     */
    @RequestMapping("/loginName")
    public Map loginName(){
        //1.得到当前登录的用户名
        String name = SecurityContextHolder.getContext().getAuthentication().getName();
        //2.将登录名放到map集合中
        Map map = new HashMap();
        map.put("name",name);
        //3.返回
        return map;
    }
}
